package com.chaowen.xuefeng.index;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.chaowen.xuefeng.OABaseActivity;
import com.chaowen.xuefeng.index.chat.ChatActivity;
import com.chaowen.yixin.R;

public class Index_Message extends OABaseActivity {
	ListView list;

	String data[] = new String[] { "China", "UK", "USA", "Japan", "German", "Canada", "ET", "Narotu" };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.oa_index_message);
		this.setTitle("消息中心");

		list = (ListView) findViewById(R.id.oa_index_message_list);
		SimpleAdapter adapter = new SimpleAdapter(this, getData(), R.layout.oa_index_message_list_item, new String[] { "title", "img" }, new int[] { R.id.title, R.id.img });
		list.setAdapter(adapter);
		list.setOnItemClickListener(lsitViewOnItemClickListener);
		list.setDividerHeight(0);
	}

	private ArrayList<HashMap<String, Object>> getData() {
		ArrayList<HashMap<String, Object>> dlist = new ArrayList<HashMap<String, Object>>();

		for (int i = 0; i < data.length; i++) {
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("title", data[i]);
			// map.put("img", R.drawable.item_left2);
			dlist.add(map);
		}
		return dlist;
	}

	private OnItemClickListener lsitViewOnItemClickListener = new OnItemClickListener() {
		@SuppressWarnings("unchecked")
		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
			ListView listView = (ListView) parent;
			HashMap<String, String> map = (HashMap<String, String>) listView.getItemAtPosition(position);
			String title = map.get("title");
			intoContent(position, title);
		}
	};

	private void intoContent(int position, String title) {
		Intent intent = null;
        /*
		switch (position) {
		case 0:// 小黑 对话界面
			break;
		case 1:
			intent = new Intent(this, Index_Content_Webview.class);
			break;

		default:
			break;
		}*/
		intent = new Intent(this, ChatActivity.class);
		Bundle bundle = new Bundle();
		bundle.putString("title", title);
		intent.putExtras(bundle);
		startActivity(intent);
	}
}
